package com.msb.api.filter.impl;

import com.msb.api.filter.CheckFilter;
import com.msb.api.util.PhoneFormatCheckUtil;
import com.msb.common.enums.ExceptionEnums;
import com.msb.common.exception.GraceException;
import com.msb.common.model.StandardSubmit;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @Author: lmf
 * @Create: 2025/3/7 9:08
 * Description: 手机号校验
 */
@Service("mobile")
@Slf4j
public class MobileCheckFilter implements CheckFilter {
    @Override
    public void check(StandardSubmit submit) {

        log.info("手机号验证mobile check");
        String mobile = submit.getMobile();
        if(StringUtils.isNotEmpty(mobile) && PhoneFormatCheckUtil.isChinaPhone(mobile)){
            log.info("手机号验证mobile check");
            return;
        }
        GraceException.display(ExceptionEnums.ERROR_MOBILE);
    }
}
